package com.nip.workmanager.activity;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ListView;

import com.nip.workmanagement.R;
import com.nip.workmanager.adapter.IconAdapter;
import com.nip.workmanager.common.ConstantIntentCode;
import com.nip.workmanager.entity.IconEntity;

public class ChooseIconCheckListActivity extends Activity implements
		OnItemClickListener {
	private ListView _lvIcon;
	private ArrayList<IconEntity> _listSource;
	private Intent _intent;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.choose_icon_activity);
		Initialize();
		_listSource = new ArrayList<IconEntity>();
		IconEntity icon = new IconEntity("No Icon", 1010101);
		_listSource.add(icon);
		icon = new IconEntity("Appointments", R.drawable.appointments);
		_listSource.add(icon);
		icon = new IconEntity("BirthDays", R.drawable.brithdays);
		_listSource.add(icon);

		IconAdapter adapter = new IconAdapter(_listSource,
				ChooseIconCheckListActivity.this);
		if (_lvIcon != null) {
			_lvIcon.setAdapter(adapter);
		}

		_lvIcon.setOnItemClickListener(this);
	}

	private void Initialize() {
		_intent = getIntent();
		_lvIcon = (ListView) findViewById(R.id.lvIcon);
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		// TODO Auto-generated method stub
		_intent.putExtra(ConstantIntentCode.CHOOSE_ICON_ID,
				_listSource.get(arg2).getIcon());
		setResult(ConstantIntentCode.CHOOSE_ICON_RESULT, _intent);
		finish();
	}
}
